*---------------------------------------------------------------------------------------------
// Stata do-file for
// Tober, T. & Busemeyer, Marius R.
// 'Breaking the Link? How European Integration Shapes Social Policy Demand and Supply'
// Journal of European Public Policy
// Table 2 and Figure 3
*---------------------------------------------------------------------------------------------

version 15
set more off

*---------------------------------------------------------------------------------------------
// Load and prepare data
*---------------------------------------------------------------------------------------------

use "data_tscs.dta", replace

xtset cntry year

*---------------------------------------------------------------------------------------------
// Table 2
*---------------------------------------------------------------------------------------------

// Model 1
xtpcse soc_prot Conformity Single_Market growth uempl party i.cntry i.year, corr(psar1)

// Model 2
xtpcse soc_prot Conformity_compliance Conformity_participation Single_Market growth uempl party i.cntry i.year, corr(psar1)

// Model 3
xtreg soc_prot Conformity_compliance Conformity_participation Single_Market l.red_pref growth uempl party i.year, fe vce(robust)

// Model 4
xtreg soc_prot Conformity_compliance Conformity_participation Single_Market l.red_pref_poor l.red_pref_rich growth uempl party i.year, fe vce(robust)

*---------------------------------------------------------------------------------------------
// Figure 3
*---------------------------------------------------------------------------------------------

// A All respondents
xtreg soc_prot Single_Market Conformity_compliance c.Conformity_participation##c.l.red_pref growth uempl party i.year, fe vce(robust)
margins, dydx(l.red_pref) at (Conformity_participation=(0 (10) 100)) atmeans post 
marginsplot, yline(0)

// B Lower income groups
xtreg soc_prot Single_Market Conformity_compliance c.Conformity_participation##c.l.red_pref_poor growth uempl party i.year, fe vce(robust)
margins, dydx(l.red_pref) at (Conformity_participation=(0 (10) 100)) atmeans post 
marginsplot, yline(0)

// C Higher income groups
xtreg soc_prot Single_Market Conformity_compliance c.Conformity_participation##c.l.red_pref_rich growth uempl party i.year, fe vce(robust)
margins, dydx(l.red_pref) at (Conformity_participation=(0 (10) 100)) atmeans post 
marginsplot, yline(0)

